package com.zhu.controller;

import com.zhu.bean.District;
import com.zhu.bean.Street;
import com.zhu.bean.Type;
import com.zhu.service.DistrictService;
import com.zhu.service.StreetService;
import com.zhu.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class DistrictController {
    @Autowired
    private DistrictService districtService;
    @Autowired
    private TypeService typeService;
    @Autowired
    private StreetService streetService;

    //当区发生变化时,显示出对应的街道
    @RequestMapping("/page/getStreet.do")
    @ResponseBody
    public List<Street> getStreet(int districtId,HttpSession session){
        List<Street> streets = streetService.getAllStreet(districtId);
        return streets;
    }
    //得到所有的户型
    @RequestMapping("/page/getType.do")
    @ResponseBody
    public List<Type> getType(HttpSession session){
        List<Type> types = typeService.getAll();
        return types;
    }
    //得到所有的城区
    @RequestMapping("/page/getDistrict.do")
    @ResponseBody
    public List<District> getDistrict(){
        List<District> districts = districtService.getAll();
        return districts;
    }
}
